﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZHDJ.Core.Util;
using ZHDJ.Data.Models.Center;
using ZHDJ.WebPage;

namespace ZHDJ.Web.Portal.PartyRepresentative
{
    public partial class SuggestionDetail : PortalPage
    {
        /// <summary>
        /// 传递ID
        /// </summary>
        private string SuggestionID
        {
            get
            {
                return this.Request["id"] ?? "null";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        public void LoadData()
        {
            var dt = PartyRepresentativeSuggestion.GetOne(SuggestionID).Tables[0];

            if (dt.Rows.Count < 1)
            {
                Response.Redirect("~/default.aspx");
            }


            txtTitle.Text = Convert.ToString(dt.Rows[0]["Title"]);
            txtUserName.Text = ControlBusiness.GetMembersPickerText(Convert.ToString(dt.Rows[0]["SuggestionBy"]));
            txtMobileNo.Text = Convert.ToString(dt.Rows[0]["MobileNo"]);
            txtMobileNo.Text = StringHelper.MobileNoHide(txtMobileNo.Text);
            ddlRepresentativeID.Text = Convert.ToString(dt.Rows[0]["RepresentativeName"]);
            txtStudioName.Text = string.Format("<a href='StudioInfo.aspx?StudioID={0}'>{1}</a>", Convert.ToString(dt.Rows[0]["StudioID"]), Convert.ToString(dt.Rows[0]["StudioName"]));
            txtContent.Text = Convert.ToString(dt.Rows[0]["Content"]);
            litStatus.Text = Convert.ToString(dt.Rows[0]["StatusName"]);
            litSuggestionCategory.Text= Convert.ToString(dt.Rows[0]["SuggestionCategoryName"]);
            txtCreateTime.Text = Convert.ToDateTime(dt.Rows[0]["CreateTime"]).ToString("yyyy-MM-dd HH:mm");
            if (Convert.ToString(dt.Rows[0]["Status"]) != "1" )
            {
                trlitHandlingType.Visible = true;
                trlitModifyBy.Visible = true;
                trlitReply.Visible = true;
                litHandlingType.Text= Convert.ToString(dt.Rows[0]["HandlingTypeName"]);
                litModifyBy.Text = ControlBusiness.GetMembersPickerText(Convert.ToString(dt.Rows[0]["ModifyBy"]));
                litReply.Text = Convert.ToString(dt.Rows[0]["Reply"]);
                litModifyTime.Text= Convert.ToDateTime(dt.Rows[0]["ModifyBy"]).ToString("yyyy-MM-dd HH:mm");
            }
            

        }

    }
}